Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Sep 24, 2025

Context picker UX improvement for @ path mentions.

Problem

  • Pressing Enter/Tab on a folder selected from the @-picker autocompleted and closed the picker, blocking keyboard drilldown.

Root cause

Solution

  • Special-case Folder selections with a concrete value:
    • Normalize to trailing slash.
    • Insert without trailing space (manual insertion logic).
    • Keep the picker open and immediately post searchFiles for the updated query to populate folder children.
    • Caret moves to end of the folder path for continued typing.

Tests

Local verification

  • cd webview-ui && npx vitest run → all UI tests passing
  • cd src && npx vitest run → all backend tests passing

Closes #8076


Important

Improves ChatTextArea context picker UX by keeping it open on folder selection and adds tests for this behavior.

  • Behavior:
    • handleMentionSelect() in ChatTextArea.tsx now keeps the context picker open for folder selections, normalizes folder paths to end with a slash, and inserts without a trailing space.
    • Initiates a searchFiles request for folder children immediately after selection.
  • Tests:
    • Adds ChatTextArea.folder-drilldown.spec.tsx to test that the input becomes "@/src/" without a trailing space and that the picker remains open.
    • Verifies searchFiles is called with the correct query for folders with and without spaces.
  • Misc:
    • Adds escapeSpaces to path-mentions imports in ChatTextArea.tsx.

This description was created by Ellipsis for eaf3974. You can customize this summary. It will automatically update as commits are pushed.

…ia Enter/Tab

Insert folder mentions without trailing space so the picker remains active. Keep the picker open and immediately query folder children to enable keyboard drilldown. Add a focused test for folder drilldown behavior. Fixes #8076.
Copilot AI review requested due to automatic review settings September 24, 2025 15:36
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. UI/UX UI/UX related or focused labels Sep 24, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Improves the UX of the @ context picker by enabling keyboard drilldown navigation into folders. Previously, selecting a folder would close the picker, preventing users from exploring nested directory structures.

  • Added special handling for folder selections to keep the picker open and append trailing slashes
  • Implemented manual insertion logic to avoid trailing spaces that would close the context menu
  • Added automated folder content search when drilling into directories

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
webview-ui/src/components/chat/tests/ChatTextArea.folder-drilldown.spec.tsx New test file verifying folder drilldown behavior and picker state management
webview-ui/src/components/chat/ChatTextArea.tsx Added special case handling for folder selections with manual insertion logic

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

setSearchQuery(nextQuery)

// Kick off a search to populate folder children
const reqId = Math.random().toString(36).substring(2, 9)
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Math.random() for request ID generation could lead to collisions. Consider using crypto.randomUUID() or a more robust ID generation method to ensure uniqueness.

Suggested change
const reqId = Math.random().toString(36).substring(2, 9)
const reqId = crypto.randomUUID()

Copilot uses AI. Check for mistakes.
Comment on lines +404 to +406
setTimeout(() => {
textAreaRef.current?.focus()
}, 0)
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using setTimeout with 0 delay is a code smell that suggests timing issues. Consider using requestAnimationFrame or a more deterministic approach to handle focus management.

Suggested change
setTimeout(() => {
textAreaRef.current?.focus()
}, 0)
requestAnimationFrame(() => {
textAreaRef.current?.focus()
})

Copilot uses AI. Check for mistakes.
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 24, 2025
roomote[bot]

This comment was marked as outdated.

hannesrudolph

This comment was marked as outdated.

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Sep 24, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 24, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found issues that need attention.

// Keep focus in the textarea for continued typing
setTimeout(() => {
textAreaRef.current?.focus()
}, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer requestAnimationFrame over a zero-delay timeout for deterministic focus after DOM updates.

// - Insert without trailing space
// - Trigger a follow-up search to show folder contents
if (type === ContextMenuOptionType.Folder && value && textAreaRef.current) {
// Normalize folder path to end with a trailing slash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When constructing a folder path manually, escape spaces before insertion; unescaped whitespace after '@' can hide the picker.

folderPath = folderPath + "/"
}

// Manually build insertion without a trailing space (more deterministic than insertMention)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual replacement (slicing/regex) is brittle for common path tokens; delegate to insertMention() and strip its trailing space to keep the menu open.


// Keep the context menu open for drill-down
setShowContextMenu(true)
setSelectedType(null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After keeping the picker open, reset the highlighted option (e.g., index 0) so Enter continues drilldown predictably.

expect(lastMsg.query).toBe("/src/")
expect(typeof lastMsg.requestId).toBe("string")
})
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test for folders with spaces: escaped insertion in the input and unescaped query in searchFiles.

…ape spaces for folder mentions and add coverage. Addresses review feedback by @daniel-lxs
@roomote
Copy link

roomote bot commented Nov 3, 2025

See this task on Roo Code Cloud

Review completed. No new blocking issues identified.

The implementation correctly addresses the reported issue of keeping the context picker open during folder drilldown. All critical concerns raised by previous reviewers have been addressed in the second commit:

  • Space escaping for folder paths with spaces
  • Test coverage for folders with spaces
  • Secure request ID generation using crypto.randomUUID()

The code correctly implements the folder drilldown feature with proper space handling, race condition prevention, and comprehensive test coverage.

Mention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request.

@hannesrudolph
Copy link
Collaborator Author

closing, will open new one.

@github-project-automation github-project-automation bot moved this from PR [Changes Requested] to Done in Roo Code Roadmap Nov 3, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR - Changes Requested size:L This PR changes 100-499 lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Tab autocompletes folder and closes picker; can't drill into folders

3 participants